const Router = require('koa-router'),
      router = new Router(),
      {folder} = require('../models');

router.prefix('/api/folders');

router.get('/',async ctx=>{

  ctx.body = await folder.getFolders(ctx.user.id);
});

router.post('/',async ctx=>{
  let {item} = ctx.request.body;

  ctx.body = await folder.addFolder(item,ctx.user.id);
});

router.put('/:id',async ctx=>{
  let {id} = ctx.params;
  let {item} = ctx.request.body;

  ctx.body = await folder.updateFolderByID(id,item,ctx.user.id);
});

router.delete('/:id',async ctx=>{
  let {id} = ctx.params;

  ctx.body = await folder.deleteFolderByID(id,ctx.user.id);
});



module.exports=router;





